n = int(input())
a_1  = b_1 = c_1 = d_1 = a_2 = b_2 = c_2 = 0
for i in range(1, n + 1):
    str = input()
    for ch in str:
        if ch >= 'a' and ch <= 'z':
            a_1 = a_2 = 1
        if ch >= 'A' and ch <= 'Z':
            b_1 = b_2 = 1
        if ch >= '0' and ch <='9':
            c_1 = c_2 =1
        if a_2 != 1 and b_2 != 1 and c_2 != 1:
            d_1 = 1
        a_2 = b_2 = c_2 = 0
    if a_1 == 1 and b_1 == 1 and c_1 == 1 and d_1 == 1 and len(str) >= 6 and len(str) <= 16:
        print("Yes")
    else:
        print("No")
    a_1 = b_1 = c_1 = d_1 = 0

